<?php global $has_permit; ?>
<div class="std_header auto_height">
    <div class="left">
        <strong><?php echo $module['title']; ?></strong>
    </div>
</div>
<div class="db_left bl">
    <?php $this->load->view('site/admin/side_block'); ?>
</div>
<div class="db_right bl">
    <?php if ($has_permit) :?>
    <div id="contact_management">
        <?php $this->load->view('site/contact/message'); ?>
        <div id="tab_store" class="tab_container">
            <ul>
                <li id="active_tab_list"><a href="#tab_list"><span>Danh sách liên hệ</span></a></li>
                <li id="active_tab_edit"><a href="#tab_edit"><span>Thông tin liên hệ</span></a></li>
            </ul>
            <div id="tab_list">
                <?php if (count($collection) != 0) : ?>
                <form action="<?php echo site_url('admin/site/contact/index', true); ?>" method="post" id="frm_contact_gridview">
                    <div class="block">
                        <table class="gridview" width="100%" cellpadding="0" cellspacing="0" border="0">
                            <thead>
                            <tr>
                                <td><b>ID</b></td>
                                <td width="300px"><b>Tên</b></td>
                                <td><b>Email</b></td>
                                <td><b>Xử lý</b></td>
                            </tr>
                            </thead>
                            <tbody>
                                <?php foreach ($collection as $contact) : ?>
                            <tr>
                                <input type="hidden" value="" class="edit_url" />
                                <td width="30px" valign="top">
                                    <?php echo $contact->id; ?>
                                </td>
                                <td width="30px" valign="top">
                                    <?php echo $contact->name; ?>
                                </td>
                                <td valign="top">
                                    <?php echo empty($contact->email) ? '<span class="empty">Empty</span>' : $contact->email; ?>
                                </td>
                                <td valign="top">
                                    <p><a class="ajax_link icon icon_edit" data="{id:<?php echo $contact->id; ?>}" selector="#tab_edit" item="#active_tab_edit a" href="<?php echo site_url('admin/site/contact/ajax_edit/id/' . $contact->id, true); ?>"></a> <a class="icon icon_delete" href="<?php echo site_url('admin/site/contact/delete/id/' . $contact->id, true); ?>" onclick="return confirm('Bạn muốn xóa thông tin liên hệ này?')"></a></p>
                                </td>
                            </tr>
                                <?php endforeach; ?>
                            </tbody>
                            <tfoot>

                            </tfoot>
                        </table>
                    </div>
                </form>
                <?php else : ?>
                <div class="error_message corner">Không tìm thấy thông tin liên hệ nào trong hệ thống</div>
                <?php endif; ?>
            </div>
            <div id="tab_edit">
                <p class="empty fade">
                    <i>Chưa có thông tin liên hệ nào được hiển thị</i>
                </p>
            </div>
        </div>
    </div>
    <?php else :?>
    <?php $this->load->view('layouts/restricted'); ?>
    <?php endif; ?>
</div>
<div class="clearfix"></div>
<script type="text/javascript">
    $("#frm_contact_edit").validate();
    var admin_site_contact = {};
    admin_site_contact.create_new = function() {
        $("#frm_contact_edit input[type='text']").val("");
        $("#frm_contact_edit textarea").val("");
        $("#frm_contact_edit select").val("0");
        $("#active_tab_edit a").trigger("click");
        $("#entity_id").val(0);
        return false;
    };
</script>